﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>

    <script src="../../linq.js"></script>

</head>
<body>
    <script type="text/javascript">


        var lists = [];
        var entity1 = {
            DepartmentCode: "345",
            OrderItemNumber: "33",
            OrderNumber: "222",

            CostCenterCode:"Q001005",
            DepartmentName:"人事部",
            KeyCode:"D08/320-01001-1",
            ProfitCenterCode:"Q000101",
            ShuntMoney:"30.00",
            WbsName:"D08/320-01001-1"
        }
        var entity2 = {
            DepartmentCode: "344",
            OrderItemNumber: "99",
            OrderNumber: "111",

            CostCenterCode: "Q001005",
            DepartmentName:"财务部",
            KeyCode:"D08/320-01016-1",
            ProfitCenterCode:"Q000101",
            ShuntMoney:"40.00",
            WbsName:"D08/320-01016-1"
        }
        var entity3 = {
            DepartmentCode: "345",
            OrderItemNumber: "33",
            OrderNumber: "222",

            DepartmentName:"人事部",
            KeyCode: "D08/320-04001",
            CostCenterCode: "Q001005",
            ProfitCenterCode:"Q000101",
            ShuntMoney:"30.00",
            WbsName:"D08/320-04001"
        }
        lists.push(entity1, entity2, entity3);
   
        var ss = Enumerable.From(lists).GroupBy("{DepartmentCode:$.DepartmentCode, OrderNumber:$.OrderNumber, OrderItemNumber:$.OrderItemNumber}"
, "$.KeyCode",
            function (key, group) {
                return {
                    DepartmentCode:key.DepartmentCode ,
                    OrderNumber: key.OrderNumber  ,
                    OrderItemNumber: key.OrderItemNumber,
                    Count: group.source.length
            }
            },
            function (key) {
                return key.DepartmentCode + key.OrderNumber + key.OrderItemNumber;
            }).WriteLine("$.DepartmentCode + ':' + $.OrderNumber+ ':'+ $.OrderItemNumber+ ':'+ $.Count");
        var s = 1;


        var objects = [
            { Date: new Date(2000, 1, 1), Id: 1 },
            { Date: new Date(2010, 5, 5), Id: 2 },
            { Date: new Date(2000, 1, 1), Id: 3 }
        ];
        Enumerable.From(objects)
            .GroupBy("$.Date", "$.Id",
                function (key, group) { return { date: key, ids: group.ToString(',') } },
                function (key) { return key.toString() })
            .WriteLine("$.date + ':' + $.ids");




        // key,e=>key+':'+e.Select('$.DepartmentName').ToArray()"
        //"key,e=>key.toString()")
    </script>
</body>
</html>